﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.UI.Selection;

namespace YArchitech.Revit
{
	public class DuctFilterBySystemName : ISelectionFilter
	{
		public DuctFilterBySystemName(string systemName)
		{
			this.sName = systemName;
		}

		public bool AllowElement(Element elem)
		{
			if (elem is Duct)
			{
				Duct duct = elem as Duct;
				if (duct == null)
				{
					return false;
				}
				if (duct.GetSystemName().Equals(this.sName))
				{
					return true;
				}
			}
			if (elem is FamilyInstance)
			{
				BuiltInCategory integerValue = elem.Category.Id.IntegerValue;
				if (integerValue != -2008016 && integerValue != -2008010)
				{
					return false;
				}
				if ((elem as FamilyInstance).GetSystemName().Equals(this.sName))
				{
					return true;
				}
			}
			return false;
		}

		public bool AllowReference(Reference reference, XYZ position)
		{
			return false;
		}

		private string sName = "";
	}
}
